package pkg

import (
	"fmt"
	"github.com/smartwalle/alipay/v3"
	"user_srv/basic/config"
)

func AliPay(orderSn, totalPrice string) string {

	var client, err = alipay.New(config.AppId, config.PrivateKey, false)
	if err != nil {
		fmt.Println(err)
		return ""
	}

	var p = alipay.TradeWapPay{}
	p.NotifyURL = config.NotifyURL
	p.ReturnURL = config.ReturnURL
	p.Subject = config.Subject
	p.OutTradeNo = orderSn
	p.TotalAmount = totalPrice
	p.ProductCode = "QUICK_WAP_WAY"

	url, err := client.TradeWapPay(p)
	if err != nil {
		fmt.Println(err)
	}
	return url.String()
}
